home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / graphics / giftxt.arc / gif.doc
Text File  |  1988-05-07  |  32KB  |  715 lines

  1.  
  2.  
  3.  
  4.                                 G I F (tm)
  5.  
  6.                      Graphics Interchange Format (tm)
  7.  
  8.  
  9.  
  10.  
  11.                       A standard defining a mechanism
  12.                      for the storage and transmission
  13.                    of raster-based graphics information
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                                June 15, 1987
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.                      (c) CompuServe Incorporated, 1987
  38.                             All rights reserved
  39.  
  40.             While this document is copyrighted, the information
  41.           contained within is made available for use in computer
  42.           software without royalties, or licensing restrictions.
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.           GIF and 'Graphics Interchange Format' are trademarks of
  50.                          CompuServe, Incorporated.
  51.                            an H&R Block Company
  52.  
  53.                         5000 Arlington Centre Blvd.
  54.                            Columbus, Ohio 43220
  55.                               (614) 457-8600
  56.                                                                      Page 2
  57.  
  58.  
  59.               Graphics Interchange Format (GIF) Specification
  60.  
  61.  
  62.                              Table of Contents
  63.  
  64.         INTRODUCTION . . . . . . . . . . . . . . . . . page 3
  65.  
  66.         GENERAL FILE FORMAT  . . . . . . . . . . . . . page 3
  67.  
  68.         GIF SIGNATURE  . . . . . . . . . . . . . . . . page 4
  69.  
  70.         SCREEN DESCRIPTOR  . . . . . . . . . . . . . . page 4
  71.  
  72.         GLOBAL COLOR MAP . . . . . . . . . . . . . . . page 5
  73.  
  74.         IMAGE DESCRIPTOR . . . . . . . . . . . . . . . page 6
  75.  
  76.         LOCAL COLOR MAP  . . . . . . . . . . . . . . . page 7
  77.  
  78.         RASTER DATA  . . . . . . . . . . . . . . . . . page 7
  79.  
  80.         GIF TERMINATOR . . . . . . . . . . . . . . . . page 8
  81.  
  82.         GIF EXTENSION BLOCKS . . . . . . . . . . . . . page 8
  83.  
  84.         APPENDIX A - GLOSSARY  . . . . . . . . . . . . page 9
  85.  
  86.         APPENDIX B - INTERACTIVE SEQUENCES . . . . . . page 10
  87.  
  88.         APPENDIX C - IMAGE PACKAGING & COMPRESSION . . page 12
  89.  
  90.         APPENDIX D - MULTIPLE IMAGE PROCESSING . . . . page 15
  91. Graphics Interchange Format (GIF)                                    Page 3
  92. Specification
  93.  
  94.  
  95. INTRODUCTION
  96.  
  97.         'GIF' (tm) is CompuServe's standard for defining generalized  color
  98.    raster   images.    This   'Graphics  Interchange  Format'  (tm)  allows
  99.    high-quality, high-resolution graphics to be displayed on a  variety  of
  100.    graphics  hardware  and is intended as an exchange and display mechanism
  101.    for graphics images.  The image format described  in  this  document  is
  102.    designed  to  support  current  and  future image technology and will in
  103.    addition serve as a basis for future CompuServe graphics products.
  104.  
  105.         The main focus  of  this  document  is  to  provide  the  technical
  106.    information  necessary  for  a  programmer to implement GIF encoders and
  107.    decoders.  As such, some assumptions are made as to terminology relavent
  108.    to graphics and programming in general.
  109.  
  110.         The first section of this document describes the  GIF  data  format
  111.    and its components and applies to all GIF decoders, either as standalone
  112.    programs or as part of  a  communications  package.   Appendix  B  is  a
  113.    section  relavent to decoders that are part of a communications software
  114.    package and describes the protocol requirements for entering and exiting
  115.    GIF mode, and responding to host interrogations.  A glossary in Appendix
  116.    A defines some of the terminology used in  this  document.   Appendix  C
  117.    gives  a  detailed  explanation  of  how  the  graphics  image itself is
  118.    packaged as a series of data bytes.
  119.  
  120.  
  121.                 Graphics Interchange Format Data Definition
  122.  
  123.  
  124.  GENERAL FILE FORMAT
  125.  
  126.         +-----------------------+
  127.         | +-------------------+ |
  128.         | |   GIF Signature   | |
  129.         | +-------------------+ |
  130.         | +-------------------+ |
  131.         | | Screen Descriptor | |
  132.         | +-------------------+ |
  133.         | +-------------------+ |
  134.         | | Global Color Map  | |
  135.         | +-------------------+ |
  136.         . . .               . . .
  137.         | +-------------------+ |    ---+   
  138.         | |  Image Descriptor | |       |   
  139.         | +-------------------+ |       |   
  140.         | +-------------------+ |       |  
  141.         | |  Local Color Map  | |       |-   Repeated 1 to n times
  142.         | +-------------------+ |       |   
  143.         | +-------------------+ |       |   
  144.         | |    Raster Data    | |       |   
  145.         | +-------------------+ |    ---+   
  146.         . . .               . . .   
  147.         |-    GIF Terminator   -|   
  148.         +-----------------------+
  149. Graphics Interchange Format (GIF)                                    Page 4
  150. Specification
  151.  
  152.  
  153.  GIF SIGNATURE
  154.  
  155.         The following GIF Signature identifies  the  data  following  as  a
  156.    valid GIF image stream.  It consists of the following six characters:
  157.  
  158.              G I F 8 7 a
  159.  
  160.         The last three characters '87a' may be viewed as a  version  number
  161.    for  this  particular  GIF  definition  and will be used in general as a
  162.    reference  in  documents  regarding  GIF  that   address   any   version
  163.    dependencies.
  164.  
  165.  SCREEN DESCRIPTOR
  166.  
  167.         The Screen Descriptor describes the overall parameters for all  GIF
  168.    images  following.  It defines the overall dimensions of the image space
  169.    or logical screen required, the existance of color mapping  information,
  170.    background  screen color, and color depth information.  This information
  171.    is stored in a series of 8-bit bytes as described below.
  172.  
  173.               bits
  174.          7 6 5 4 3 2 1 0  Byte #
  175.         +---------------+
  176.         |               |  1
  177.         +-Screen Width -+      Raster width in pixels (LSB first)
  178.         |               |  2
  179.         +---------------+
  180.         |               |  3
  181.         +-Screen Height-+      Raster height in pixels (LSB first)
  182.         |               |  4
  183.         +-+-----+-+-----+      M = 1, Global color map follows Descriptor
  184.         |M|  cr |0|pixel|  5   cr+1 = # bits of color resolution
  185.         +-+-----+-+-----+      pixel+1 = # bits/pixel in image
  186.         |   background  |  6   background=Color index of screen background
  187.         +---------------+          (color is defined from the Global color
  188.         |0 0 0 0 0 0 0 0|  7        map or default map if none specified)
  189.         +---------------+
  190.  
  191.  
  192.         The logical screen width and height can both  be  larger  than  the
  193.    physical  display.   How  images  larger  than  the physical display are
  194.    handled is implementation dependent and can take advantage  of  hardware
  195.    characteristics  (e.g.   Macintosh scrolling windows).  Otherwise images
  196.    can be clipped to the edges of the display.
  197.  
  198.         The value of 'pixel' also defines  the  maximum  number  of  colors
  199.    within  an  image.   The  range  of  values  for 'pixel' is 0 to 7 which
  200.    represents 1 to 8 bits.  This translates to a range of 2 (B & W) to  256
  201.    colors.   Bit  3 of word 5 is reserved for future definition and must be
  202.    zero.
  203. Graphics Interchange Format (GIF)                                    Page 5
  204. Specification
  205.  
  206.  
  207.  GLOBAL COLOR MAP
  208.  
  209.         The Global Color Map is optional but recommended for  images  where
  210.    accurate color rendition is desired.  The existence of this color map is
  211.    indicated in the 'M' field of byte 5 of the Screen Descriptor.  A  color
  212.    map  can  also  be associated with each image in a GIF file as described
  213.    later.  However this  global  map  will  normally  be  used  because  of
  214.    hardware  restrictions  in equipment available today.  In the individual
  215.    Image Descriptors the 'M' flag will normally be  zero.   If  the  Global
  216.    Color  Map  is  present,  it's definition immediately follows the Screen
  217.    Descriptor.   The  number  of  color  map  entries  following  a  Screen
  218.    Descriptor  is equal to 2**(# bits per pixel), where each entry consists
  219.    of three byte values representing the relative intensities of red, green
  220.    and blue respectively.  The structure of the Color Map block is: